﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>register</title>
    <link rel="shortcut icon" href="/images/acm.ico" type="image/x-icon" />
    <link rel="stylesheet" type="text/css" href="http://kao.acmcoder.com/css/jquery.cxdialog.css"  />
    <link rel="stylesheet" type="text/css" href="http://kao.acmcoder.com/css/all-exam.css"  />
    <link rel="stylesheet" type="text/css" href="http://kao.acmcoder.com/css/user/login.css"  />
    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
</head>
<body>
    <!--head-->
    <div class="head">
        <div class="head-bar public">
            <div class="logo">
                <a href="javascript:if(confirm('http://kao.acmcoder.com/  \n\n���ļ��޷��� Teleport Ultra ����, ��Ϊ ����һ�����·���ⲿ������Ϊ������ʼ��ַ�ĵ�ַ��  \n\n�����ڷ������ϴ���?'))window.location='http://kao.acmcoder.com/'" tppabs="http://kao.acmcoder.com/"><img src="logo-1.png" tppabs="http://kao.acmcoder.com/images/logo.png" /></a>
                <p><span>家用版</span></p>
            </div>
        </div>
    </div>
    <!--head  end-->
    <div class="acm-container" style="padding-bottom:200px;">
        <div class="userCnt">
            <div class="loginCnt">
                <h1>家用注册</h1>
                
                    <div class="login-box">
                        <ul>
                            <li>
                                <span class="regisit-span">+86</span>
                                <input type="text" name="phone_ipt" id="phone_ipt" class="login-text input regisit-phone" placeholder="请输入手机号" maxlength="11" />
                            </li>
                            <li>
                                <input type="text" name="vcode_ipt" id="vcode_ipt" class="login-text input regisit-send-input" placeholder="验证码" />
                                <a href="javascript:void(0)" id="get_mob_yzm_btn" class="regisit-send">获取验证短信</a>
                            </li>
                            <li>
                                <input type="password" name="pwd_ipt" id="pwd_ipt" class="login-text input" placeholder="请输入密码，至少6位" maxlength="20" />
                            </li>
                            <li>
                                <input type="password" name="pwd2_ipt" id="pwd2_ipt" class="login-text input" placeholder="重复输入密码" />
                            </li>
                            <li class="login-t">

                                <div class="clear"></div>
                            </li>
                            <li>
                               <input type="button" id="sbtn" value="提交注册" class="login-btn btn"/>
                            </li>
                        </ul>
                    </div>
               
             
                <div class="login-f">
                    已有账号，<a href="login-1.htm" tppabs="http://kao.acmcoder.com/enterprise/login">马上登录 >></a>
                </div>
            </div>
        </div>
    </div>
    <!--验证码弹窗 end-->
    <!--footer-->
    <!--footer end-->
    <script src="http://kao.acmcoder.com/js/jquery.min.js" tppabs="" type="text/javascript" charset="utf-8"></script>
    <script src="http://kao.acmcoder.com/js/jquery.cxdialog.js" tppabs="" type="text/javascript" charset="utf-8"></script>
    <script src="http://kao.acmcoder.com/js/all.js" tppabs="" type="text/javascript" charset="utf-8"></script>
    <script src="http://kao.acmcoder.com/js/user/regisit.js" tppabs="" type="text/javascript" charset="utf-8"></script>
    <script src="http://kao.acmcoder.com/js/common.min.js" tppabs="" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="https://cdn.acmcoder.com/static/1.0.1/js/jquery.cookie.js" tppabs=""></script>
    <script src="http://kao.acmcoder.com/js/footer-exam.js" tppabs="" type="text/javascript" charset="utf-8"></script>
</body>
</html>
<script>
        var InterValObj;
        var curCount;
        // timer处理函数
        var SetRemainTime = function () {
            if (curCount == 0) {
                window.clearInterval(InterValObj);//停止计时器
                $('#get_mob_yzm_btn').removeAttr('disabled');//启用按钮
                $('#get_mob_yzm_btn').text('重新发验证码');
            } else {
                curCount--;
                $('#get_mob_yzm_btn').text(curCount + 's后重新获取');
            }
        };
        // 获取验证码
        $(document).on('click', '#get_mob_yzm_btn', function () {
            var mobile = $('#phone_ipt').val();
            if (InterValObj && curCount > 0) {
                return;
            }
            curCount = 59;
            //设置button效果，开始计时
            $(this).attr('disabled', 'true');
            $(this).text(curCount + 's后重新获取');

            InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器，1秒执行一
            $.ajax({
                url: "/Login/Ynzheng",
                type: 'post',
                dataType: 'json',
                data: { phone: mobile },
                success: function (data) {
                    if (data == 1) {
                      
                    }
                    else {
                        alert("发送验证码失败，请联系管理员");
                    }
                    return;
                }
            });
        });
        $("#sbtn").click(function () {
            $.ajax({
                url: "/Login/register",
                type: "post",
                data: { phone_ipt: $('#phone_ipt').val(), vcode_ipt: $("#vcode_ipt").val(), pwd_ipt: $("#pwd_ipt").val(), pwd2_ipt: $("#pwd2_ipt").val() },
                success:function(data)
                {
                    if(data>0)
                    {
                        location.href = "/Login/Login";
                    }
                    if(data==-1)
                    {
                        alert("请填写完整信息");
                        
                    }
                    else if(data==-2)
                    {
                        alert("验证错误");
                        $("#vcode_ipt").val("");
                        $("#vcode_ipt").focus();
                    }
                    else if (data == -3) {
                        alert("密码输入的不一致");
                        $("#pwd_ipt").val("");
                        $("#pwd2_ipt").val("");
                        $("#pwd_ipt").focus();
                    }
                    else if (data == -4) {
                        alert("保存失败，请核实信息");
                        $('#phone_ipt').val("");
                        $("#vcode_ipt").val("");
                        $("#pwd_ipt").val("");
                        $("#pwd2_ipt").val("");
                        $('#phone_ipt').focus();
                    }

                }
            })
        })
        $("#phone_ipt").change(function () {
            $.ajax({
                url: "/Login/verification",
                type: "post",
                data: { Phone: $("#phone_ipt").val() },
                success:function(data)
                {
                    if(data>0)
                    {
                        alert("用户已存在");
                        $("#phone_ipt").val("");
                        $("#phone_ipt").focus();
                    }
                    else if(data==-1)
                    {
                        alert("手机号格式不对");
                        $("#phone_ipt").val("");
                        $("#phone_ipt").focus();
                    }
                }
            })
        })
</script>
